package com.lhb.user.config;

import com.lhb.user.Interceptors.UserInfoInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    
    @Autowired
    private UserInfoInterceptor userInfoInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器并配置拦截路径
        registry.addInterceptor(userInfoInterceptor)
                .addPathPatterns("/**")           // 拦截所有路径
                .excludePathPatterns("/user");   // 排除登录路径
    }
}